.. _cmmStReadMotionState: cmmStReadMotionState ======================== ------------------------ SYNOPSIS ``````````` .. code-block:: none VT_I4 cmmStReadMotionState( [in] VT_I4 Axis, [out] VT_PI4 MotStates ) DESCRIPTION ``````````````` - 이 함수는 현재 모션의 동작 상태를 반환합니다. PARAMETER ``````````` - Axis: 축번호. 축번호는 상수값으로 [cmX1] 부터 0 번째 축을 기준 축으로 임의의 축을 설정할 수 있습니다. \ - MotStates : 모션 상태. .. csv-table:: :widths: 10 85 :header-rows: 1 :stub-columns: 0 Value, Meaning 음수, 모션작업 도중 에러 발생 => 에러코드 참조. 0 또는 cmMST_STOP, Stop 1 또는 cmMST_WAIT_DR, Waiting for DR input signal 2 또는 cmMST_WAIT_STA, Waiting for STA input signal 3 또는 cmMST_WAIT_INSYNC, Waiting for internal sync. signal 4 또는 cmMST_WAIT_OTHER, Waiting other axis 5 또는 cmMST_WAIT_ERC, Waiting for ERC output finished 6 또는 cmMST_WAIT_DIR, Waiting for DIR change (DIR 은 외부입력 신호가 아닌 내부적인 신호임) 7 또는 cmMST_RESERVED1, Reserved 8 또는 cmMST_WAIT_PLSR, Waiting for PA/PB input signal 9 또는 cmMST_IN_RVSSPD, In home special speed (reverse speed) 10 또는 cmMST_IN_INISPD, In start velocity motion 11 또는 cmMST_IN_ACC, In acceleration 12 또는 cmMST_IN_WORKSPD, In working velocity 13 또는 cmMST_IN_DEC, In deceleration 14 또는 cmMST_WAIT_INP, Waiting for INP input signal 15 또는 cmMST_SPARE0, Reserved \ - Position : 대상 카운터에 설정될 값. 단, 이 값은 논리적 거리 단위로 설정하여야 합니다. RETURN VALUE ````````````` .. csv-table:: :widths: 10 85 :header-rows: 1 :stub-columns: 0 Value, Meaning 음수, 수행 실패 cmERR_NONE, 수행 성공 REFERENCE ``````````` - 논리적 거리 단위는 cmmCfgSetUnitDist() 함수에 의해 결정됩니다. EXAMPLE ``````````` .. code-block:: c++ :linenos: :emphasize-lines: 5 C/C++ char szMstList[16][20] = { "Stop", "Wait DR", "Wait STA", "Wait INSYNC", "Wait other axis", "Wait ERC", "Wait DIR", "Reserved1", "Wait PA/PB", "On reverse speed", "On initial speed", "On acceleration", "On work speed", "On deceleration", "Wait INP", ""}; long nMST; cmmStReadMotionState(cmX1, &nMST); if(nMST < 0){ // Status 가 0 보다 작으면 마지막 모션에서 에러 발생한 상태 cmmErrShowLast(Handle); } ////////////////////////////////////////////////////////////// // DisplayStatus() 함수는 MessageBox 와 같이 화면에 상태를 표시하는 가상의 함수입니다. CString sMsg = “Current Motion State : “ + szMstList[nMST]; DisplayStatus(sMsg) } .. code-block:: none :linenos: Visual Basic Private Sub Timer1_Timer() Dim state As Long If (cmmStReadMotionState(cmX1, state) <> cmERR_NONE) Then Call cmmErrShowLast(Handle) End If Select Case state Case cmMST_STOP: lblState.Caption = "Stop" Case cmMST_WAIT_DR: lblState.Caption = "Waiting for DR input signal" Case cmMST_WAIT_STA: lblState.Caption = "Waiting for STA input signal" Case cmMST_WAIT_INSYNC: lblState.Caption = "Waiting for internal sync, signal" Case cmMST_WAIT_OTHER: lblState.Caption = "Waiting other axis" Case cmMST_WAIT_ERC: lblState.Caption = "Waiting for ERC output finished" Case cmMST_WAIT_DIR: lblState.Caption = "Waiting for DIR change" ' 아래 cmMST_RESERVED1 은 내부적으로 예약되었기 때문에 사용하지 않습니다. 'Case cmMST_RESERVED1 : lblState.Caption = "RESERVED1" Case cmMST_WAIT_PLSR: lblState.Caption = "Waiting for PA/PB input signal" Case cmMST_IN_RVSSPD: lblState.Caption = "In home special speed (reverse speed)" Case cmMST_IN_INISPD: lblState.Caption = "In start velocity motion" Case cmMST_IN_ACC: lblState.Caption = "In Acceleration" Case cmMST_IN_WORKSPD: lblState.Caption = "In Working Velocity" Case cmMST_IN_DEC: lblState.Caption = "In Deceleration" Case cmMST_WAIT_INP: lblState.Caption = "Waiting for INP input signal ' 아래 cmMST_SPARE0 는 내부적으로 예약되었습니다. 사용하지 않습니다. ' Case cmMST_SPARE0 : lblState.Caption = "RESERVED2" End Select End Sub .. code-block:: none :linenos: Delphi function GetMitonStateString( i : Integer ) : String; begin Case i of cmMST_STOP : Result := 'Stop'; cmMST_WAIT_DR : Result := 'Waiting for DR input signal'; cmMST_WAIT_STA : Result := 'Waiting for STA input signal'; cmMST_WAIT_INSYNC : Result := 'Waiting for internal sync, signal'; cmMST_WAIT_OTHER : Result := 'Waiting other axis'; cmMST_WAIT_ERC : Result := 'Waiting for ERC output finished'; cmMST_WAIT_DIR : Result := 'Waiting for DIR change'; // cmMST_RESERVED1 은 내부적으로 예약되었습니다. 사용하지 않습니다. //cmMST_RESERVED1 : Result := 'RESERVED1'; cmMST_WAIT_PLSR : Result := 'Waiting for PA/PB input signal'; cmMST_IN_RVSSPD : Result := 'In home special speed (reverse speed)'; cmMST_IN_INISPD : Result := 'In start velocity motion'; cmMST_IN_ACC : Result := 'In Acceleration'; cmMST_IN_WORKSPD : Result := 'In Working Velocity'; cmMST_IN_DEC : Result := 'In Deceleration'; cmMST_WAIT_INP : Result := 'Waiting for INP input signal'; // cmMST_SPARE0 는 내부적으로 예약되었습니다. 사용하지 않습니다. //cmMST_SPARE0 : Result := 'RESERVED2'; end; end; procedure OnEvent(); var stateus : LongInt; i : Integer; begin // 에러 발생하면, 에러 메시지를 화면에 나타냅니다. if ( cmmStReadMotionState(cmX1, @stateus) <> cmERR_NONE ) then begin ShowMessage('cmmStReadMotionState has been failed'); // 또는 cmmErrShowLast(self.Handle); exit; end; if ( stateus < 0 ) then begin ShowMessage('모션 동작 상태에 에러가 발생하였습니다.'); // 또는 cmmErrShowLast(self.Handle); // OnEvent procedure 를 종료합니다. exit; end; end;